import java.rmi.StubNotFoundException;
import java.util.*;
public class main23{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String a= new String();
        a=in.nextLine();
        int n=a.length();
        System.out.println(a);
        int m=n;
        for(int i=n-1;i>=0;i--){
            if(a.charAt(i)==' '){
                for(int e=i+1;e<m;e++){
                    System.out.print(a.charAt(e));
                }
                m=i;
                System.out.print(" ");
            }
            
            if(i==0){
                for(int e=0;e<m;e++){
                    System.out.print(a.charAt(e));
                }
            }
        }
    }
}